package com.project.service.impl;

import com.project.bean.RoomBean;
import com.project.mapper.IClassMapper;
import com.project.mapper.IRoomMapper;
import com.project.service.IRoomService;
import org.apache.ibatis.session.SqlSession;

import java.util.List;

public class RoomService extends BaseService implements IRoomService {
    @Override
    public List<RoomBean> finAllRoom() {
        SqlSession session=this.getSession();
        IRoomMapper mapper=session.getMapper(IRoomMapper.class);
        List<RoomBean>list=mapper.finAllRoom();
        session.close();
        return list;
    }

    @Override
    public List<RoomBean> findByItems(String address, String ifok, String status, String type) {
        SqlSession session=this.getSession();
        IRoomMapper mapper=session.getMapper(IRoomMapper.class);
        List<RoomBean>list=mapper.findByItems(address,ifok,status,type);
        session.close();
        return list;
    }

    @Override
    public void addRoom(RoomBean roomBean) {
        SqlSession session=this.getSession();
        IRoomMapper mapper=session.getMapper(IRoomMapper.class);
        mapper.addRoom(roomBean);
        session.commit();
        session.close();


    }

    @Override
    public boolean deleteRoom(int roomId) {
        SqlSession session=this.getSession();
        IRoomMapper mapper=session.getMapper(IRoomMapper.class);
        mapper.deleteRoom(roomId);
        session.commit();
        session.close();
        return false;
    }

    @Override
    public RoomBean findById(int roomId) {
        SqlSession session=this.getSession();
        IRoomMapper mapper=session.getMapper(IRoomMapper.class);
        RoomBean room=mapper.findById(roomId);
        session.close();
        return room;

    }
}
